package string;

/**
 * Created with IntelliJ IDEA.
 * Description: 344.反转字符串
 * User: Li_yizYa
 * Date: 2025—04—07
 * Time: 20:04
 */
public class Solution1 {
    public static void main(String[] args) {
        String str = "abcdefg";
        char[] c = str.toCharArray();
        reverseString(c);
        for (char i : c) {
            System.out.print(i + " ");
        }
    }
    private static void reverseString(char[] c) {
        if (c == null || c.length == 0) {
            return;
        }
        int left = 0;
        int right = c.length - 1;
        while (left < right) {
            char tmp = c[left];
            c[left] = c[right];
            c[right] = tmp;
            left++;
            right--;
        }
    }
}
